<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="u" uri="/iuie-tag"%>
<%@ taglib prefix="sys" uri="/sys-tag" %>
<%@ taglib prefix="lui" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增用户设置模板</title>
</head>
<lui:context/>
<u:View basePath="/res-system/setting" userJS="userSettingTemplateAdd" delayLoadJs="false">
<body>
    <lui:dialogBody>
    	<sys:dropCodeSet codeTypes="valueType" id="codeSet"/>
        <form class="m-cust m-narrow" id='userSettingTemplateAddFrm'>
        	<div class="form-group m-narrow row">
			    <div class="col-xs-12">
			        <div class="col-xs-3">
			            <label class='m-label m-float-right required' for="resName">模板名称：</label>
			        </div>
			        <div class="col-xs-8">
			            <input class='m-input form-control' id='resName' name='resName' data-validate='true' data-not-empty='true' 
        					data-empty-text="模板名称不能为空" maxlength="100" >
			        </div>
			    </div>
			</div>
			<div class="form-group m-narrow row">
			    <div class="col-xs-12">
			        <div class="col-xs-3">
			            <label class='m-label m-float-right required' for="resExt1">模板Key：</label>
			        </div>
			        <div class="col-xs-8">
			            <input class='m-input form-control' id='resExt1' name='resExt1' data-validate='true' data-not-empty='true' 
        					data-empty-text="模板Key不能为空" maxlength="100" >
			        </div>
			    </div>
			</div>
			<div class="form-group m-narrow row">
			    <div class="col-xs-12">
			        <div class="col-xs-3">
			            <label class='m-label m-float-right required' for="resExt2">值类型：</label>
			        </div>
			        <div class="col-xs-8">
						<lui:dropList id="resExt2" name="resExt2" className="form-control m-input" dropValues="codeSet.valueType"/>
			        </div>
			    </div>
			</div>
			<div class="form-group m-narrow row">
			    <div class="col-xs-12">
			        <div class="col-xs-3">
			            <label class='m-label m-float-right required' for="enabled">是否启用：</label>
			        </div>
			        <div class="col-xs-8">
			            <select name="enabled" id="enabled" class="form-control m-input">
						    <option value="">请选择</option>
						    <option value="0">禁用</option>
						    <option value="1" selected="selected">启用</option>
						</select>
			        </div>
			    </div>
			</div>
			<div class="form-group m-narrow row">
			    <div class="col-xs-12">
			        <div class="col-xs-3">
			            <label class='m-label m-float-right' for="resDesc">模板描述：</label>
			        </div>
			        <div class="col-xs-8">
			            <textarea class='m-input form-control' id='resDesc' name='resDesc' maxlength="200" ></textarea>
			        </div>
			    </div>
			</div>
			<input name="resType" value="userSetting" hidden="hidden">
        	<c:choose>
        		<c:when test="${empty requestScope.resId }">
		        	<lui:ajax id="userSettingTemplateSaveAjax" url="${ctx }/setting/template/add" formQuery="#userSettingTemplateAddFrm" 
		    			formSubmit="true" onSuccess="UserSettingTemplateAddPage.onSaveSucc" type="post" contentType="application/x-www-form-urlencoded"/>
        		</c:when>
        		<c:otherwise>
        			<lui:ajax id="userSettingTemplateSaveAjax" url="${ctx }/setting/template/update/${requestScope.resId }" formQuery="#userSettingTemplateAddFrm" 
		    			formSubmit="true" onSuccess="UserSettingTemplateAddPage.onSaveSucc" type="post" contentType="application/x-www-form-urlencoded"/>
		    		<lui:ajax id="findByIdAjax" url="${ctx }/setting/template/find/id/${requestScope.resId }" onSuccess="UserSettingTemplateAddPage.findByIdSucc" 
		    			type="get" contentType="application/x-www-form-urlencoded" autoSend="true"/>
        		</c:otherwise>
        	</c:choose>
        </form>
    </lui:dialogBody>
    <lui:dialogFooter>
       <button class="btn btn-primary m-btn" type="button" onclick="UserSettingTemplateAddPage.save()">保存</button>
       <button class="btn btn-default m-btn" type="button" data-dismiss="dialog-box">关闭</button>
    </lui:dialogFooter>
</body>
</u:View>
</html>